From cb5a0cf70790578e2dbf3621ce05fc3064173051 Mon Sep 17 00:00:00 2001 From: robertl Date: Thu, 24 Jun 2004 17:19:21 +0000 Subject: [PATCH] Add icon handling for Garmin 12, II, 38, 45, etc. --- gpsbabel/garmin.c | 60 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/gpsbabel/garmin.c b/gpsbabel/garmin.c index 1847a07cc..b9045bc5e 100644 --- a/gpsbabel/garmin.c +++ b/gpsbabel/garmin.c @@ -49,6 +49,9 @@ arglist_t garmin_args[] = { { 0, 0, 0, 0} }; +static const char * d103_symbol_from_icon_number(unsigned int n); +static int d103_icon_number_from_symbol(const char *s); + static void rw_init(const char *fname) { @@ -169,10 +172,17 @@ waypt_read(void) wpt_tmp->shortname = xstrdup(way[i]->ident); wpt_tmp->description = xstrdup(way[i]->cmnt); + rtrim(wpt_tmp->shortname); + rtrim(wpt_tmp->description); wpt_tmp->longitude = way[i]->lon; wpt_tmp->latitude = way[i]->lat; - wpt_tmp->icon_descr = - mps_find_desc_from_icon_number(way[i]->smbl, PCX); + if (gps_waypt_type == 103) { + wpt_tmp->icon_descr = d103_symbol_from_icon_number( + way[i]->smbl); + } else { + wpt_tmp->icon_descr = mps_find_desc_from_icon_number( + way[i]->smbl, PCX); + } /* * If a unit doesn't store altitude info (i.e. a D103) * gpsmem will default the alt to INT_MAX. Other units @@ -434,6 +444,12 @@ waypoint_write(void) } else { icon = mps_find_icon_number_from_desc(wpt->icon_descr, PCX); } + /* For units that support tiny numbers of waypoints, just + * overwrite that and go very literal. + */ + if (gps_waypt_type == 103) { + icon = d103_icon_number_from_symbol(wpt->icon_descr); + } way[i]->smbl = icon; if (wpt->altitude != unknown_alt) { way[i]->alt = wpt->altitude; @@ -594,3 +610,43 @@ ff_vecs_t garmin_vecs = { data_write, garmin_args }; + +static const char *d103_icons[16] = { + "dot", + "house", + "gas", + "car", + "fish", + "boat", + "anchor", + "wreck", + "exit", + "skull", + "flag", + "camp", + "circle_x", + "deer", + "1st_aid", + "back-track" +}; + +static const char * +d103_symbol_from_icon_number(unsigned int n) +{ + if (n <= 15) + return d103_icons[n]; + else + return "unknown"; +} + +static int +d103_icon_number_from_symbol(const char *s) +{ + int i; + + for (i = 0; i < sizeof(d103_icons) / sizeof(d103_icons[0]); i++) { + if (0 == case_ignore_strcmp(s, d103_icons[i])) + return i; + } + return 0; +} -- 2.30.2